import http from './api.js';

let baseUrl,baseUrlBack;
if(process.env.NODE_ENV === 'development'){// 开发环境
    baseUrl = 'http://47.92.32.156:8081/wx';
    baseUrlBack = 'https://test.yueyangshuyuan.com/api/wx'

    // baseUrl = 'https://uc.yueyangshuyuan.com/wx'
    // baseUrlBack='https://yueyangshuyuan.com/api/wx'
}else{ // 生产环境
    baseUrl = 'https://*****.com/'
}
// const root = "https://test.yueyangshuyuan.com";
const root = "https://yueyangshuyuan.com";

export const fixeParam = () => {
  let dateFormate = Date.parse(new Date());
  return {
    dateFormate:dateFormate
  };
}
export default {
  //用于上传头像获取当前的接口地址  
  baseUrlBackUrl(){
    return `${baseUrlBack}`;
  },
  //获取code
	LoginCode(params){
		params = Object.assign(params,fixeParam());
		return http.httpRequest('POST',`${baseUrl}/login`,params)
  },
  //退出登录
  LoginOut(params){
		params = Object.assign(params,fixeParam());
		return http.httpTokenRequest('POST',`${baseUrl}/logout`,params)
  },
  //绑定微信号
  bindWxUserInfo(params){
		params = Object.assign(params,fixeParam());
		return http.httpTokenRequest('POST',`${baseUrl}/bindWxUserInfo`,params)
  },
  //绑定手机号
  wxPhoneLogin(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('POST',`${baseUrl}/wxPhoneLogin?&code=${params.code}`,params)
  },
  //获取用户信息
  getUser(params){
		params = Object.assign(params,fixeParam());
		return http.httpTokenRequest('GET',`${baseUrlBack}/user/info`,params)
  },
  //获取验证码
  captcha(params){
		params = Object.assign(params,fixeParam());
		return http.httpRequest('POST',`${baseUrl}/captcha`,params)
  },
  //自己手机号注册登录
  phoneLogin(params){
    params = Object.assign(params,fixeParam());
    return http.httpRequest('POST',`${baseUrl}/phoneLogin`,params)
  },
   //获取详情接口
   merchDetail(params,merchId){
    params = Object.assign(params,fixeParam());
    if(uni.getStorageSync('token')){
      return http.httpTokenRequest('GET',`${baseUrlBack}/merch/`+merchId,params)
    }else {
          return http.httpRequest('GET',`${baseUrlBack}/merch/`+merchId,params)
    }
  },
  getServicePhone(){//获取客服电话
    return http.httpTextPlainRequest('GET',`${baseUrlBack}/call/phone`)
  },
  //设置用户信息
  setUser(params){
	params = Object.assign(params,fixeParam());
	return http.httpTokenRequestPut('PUT',`${baseUrl}/user`,params)
  },
  upToken(params){//七牛文件上传token
	  params = Object.assign(params,fixeParam());
	  return http.httpRequest('GET',`${root}/upToken`,params)
  },
  //七牛上传图片
  uploadQiniu(params){
    params = Object.assign(params,fixeParam());
    return http.httpRequest('POST',`http://upload-z1.qiniup.com`,params)
  },
  
  //收藏接口  POST /api/wx/sojourn/merch/collect
  collectAdd(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequestPut('POST',`${baseUrlBack}/sojourn/merch/collect`,params)
  },
  //取消收藏接口
  collectDelect(params,merchId){
  	params = Object.assign(params,fixeParam());
  	return http.httpTokenRequestPut('DELETE',`${baseUrlBack}/sojourn/merch/collect?merchId=`+merchId,params)
  },
  //收藏列表接口
  // GET /api/wx/sojourn/merch/collect/list
  collectList(params){
  		params = Object.assign(params,fixeParam());
  		return http.httpTokenRequestPut('GET',`${baseUrlBack}/sojourn/merch/collect/list`,params)
  },
  //获取bannerlist
  getBannerList(params){
  	params = Object.assign(params,fixeParam());
  	return http.httpTokenRequestPut('GET',`${baseUrlBack}/banner/on`,params)
  },
  //获取楼层列表
  getLayoutList(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequestPut('GET',`${baseUrlBack}/layout/type/${params.layoutType}`)
  },
  //GET /upToken
  // upToken(params){
  // 		params = Object.assign(params,fixeParam());
  // 		return http.httpTokenRequestPut('GET',`${baseUrlBack}/upToken`,params)
  // },
  
  //GET /api/wx/project/{projectId}
  projectList(params,projectId){
	  params = Object.assign(params,fixeParam());
	  return http.httpRequest('GET',`${baseUrlBack}/project/`+projectId,params)
  },
  //GET /api/wx/merch/page
  merchPage(params){
  	  params = Object.assign(params,fixeParam());
  	  return http.httpRequest('GET',`${baseUrlBack}/merch/page`,params)
  },
  merchCalendar(params){//商品日历
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequestPut('GET',`${baseUrlBack}/merch/${params.id}/price/calendar`,params)
  },
  merchCalculate(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequestPut('GET',`${baseUrlBack}/merch/${params.id}/price/calculate?count=${params.count}&sales=${params.sales}`,params)
  },
  //新建出游人POST /api/wx/tourist
  tourist(params){
      params = Object.assign(params,fixeParam());
      return http.httpTokenRequest('POST',`${baseUrlBack}/tourist`,params)
  },
  //GET /api/wx/tourist/mine 出游人列表
  touristMine(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/tourist/mine`,params)
  },
  //删除出游人
  // DELETE /api/wx/tourist/{touristId}
  delectTourist(params,touristId){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequestPut('DELETE',`${baseUrlBack}/tourist/`+touristId,params)
  },
  //GET /api/wx/tourist/{touristId}
  touristDetail(params,touristId){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/tourist/`+touristId,params)
  },

  //PUT /api/wx/tourist 编辑出游人
  ediorTourist(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('PUT',`${baseUrlBack}/tourist`,params)
  },
  //api/wx/order 下订单
  PostOrder(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('POST',`${baseUrlBack}/order`,params)
  },
  //api/wx/mine 我的订单
  myOrder(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/order/mine`,params)
  },
  //api/wx/mine 订单详情
  orderDetail(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/order/${params.id}`,params)
  },
  //api/wx/mine 订单详情
  orderTimeline(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/order/${params.id}/timeline`,params)
  },
  //订单预支付
  orderPrepay(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/order/pay/prepay`,params)
  },
  //支付成功通知后台
  orderResult(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('PUT',`${baseUrlBack}/order/pay/paid/result?orderId=${params.id}`,params)
  },
  //校验库存
  checkInventory(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/order/checkInventory`,params)
  },

  // 查询默认的会员商品信息
  // GET /api/wx/memberMerch/default
  defaultVip(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequest('GET',`${baseUrlBack}/memberMerch/default`,params)
  },
  //POST /api/wx/memberMerch/order
  memberMerchOrderVip(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequestPut('POST',`${baseUrlBack}/memberMerch/order`,params)
  },
  shareInfo(params){
    params = Object.assign(params,fixeParam());
    return http.httpTokenRequestPut('POST',`${baseUrlBack}/share?merchId=${params.merchId}&type=${params.type}`,params)
  },
}
 